package com.rongmei.jdsync.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ImageExtractorUtil {

    private static final Pattern IMG_PATTERN = Pattern.compile("<img[^>]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>");

    public static List<String> extractImages(String htmlContent) {
        List<String> imageUrls = new ArrayList<>();
        if (htmlContent == null || htmlContent.isEmpty()) {
            return imageUrls;
        }

        Matcher matcher = IMG_PATTERN.matcher(htmlContent);
        while (matcher.find()) {
            imageUrls.add(matcher.group(1));
        }

        return imageUrls;
    }
}